<?php
class cls_serve_search extends cls_serve_base
{
	function keywords_search($query_type,$query,$sort_name,$sort_order)
	{
		$search_data=cls_data_base::get_instance($this->name);
		$search_re=$search_data->keywords_search($query_type,$query,$sort_name,$sort_order);
		return $search_re;
	}
	
	function discount_search($discount_id,$sort_name,$sort_order)
	{
		$search_data=cls_data_base::get_instance($this->name);
		$search_re=$search_data->discount_search($discount_id,$sort_name,$sort_order);
		return $search_re;
	}
	
	function discount_info($discount_id)
	{
		$search_data=cls_data_base::get_instance($this->name);
		$discount_info=$search_data->discount_info($discount_id);
		return $discount_info;
	}
	
	function available_discount()
	{
		$search_data=cls_data_base::get_instance($this->name);
		$discount_info=$search_data->available_discount();
		return $discount_info;
	}
	
	function get_current_price($product_id)
	{

		$product_data = cls_data_base::get_instance($this->name);
		$product_info=$product_data->get_product_info($product_id);
		$discount_info=$product_data->get_product_discount($product_id);
		if ($discount_info['DiscountType']==1&&$discount_info['Status']==1)
		{
			$current_price=$product_info['Price']*$discount_info['Amount'];
			return $current_price;
		}
		if ($discount_info['DiscountType']==2&&$discount_info['Status']==1)
		{
			$current_price=$product_info['Price']-$discount_info['Amount'];
			return $current_price;
		}
		else
			return $product_info['Price'];
	}
}